package com.zixun.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class MyHelper extends SQLiteOpenHelper {

    private static String DB_NAME = "mydata.db";
    public static String TABLE_NAME = "home";//首页

    public static String GROWUP_NAME = "growup";//成长发展
    public static String LOVE_NAME = "love";//婚恋问题
    public static String RELATIONSHIP_NAME = "relationship";//人际关系
    public static String MENTAL_DISORDER_NAME = "mentaldisorder";//心理障碍

    public static String DOCTOR_NAME = "doctor";//医生
    public static String USER_INFO_TABLE = "userInfo";//用户表
    public static String DIARY_TABLE = "diaryInfo";//心情日记

    public MyHelper(Context context) {
        super(context, DB_NAME, null, 2);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {

        //创建成长发展
        String sql5 = "CREATE TABLE " + GROWUP_NAME + "("
                + "_id INTEGER PRIMARY KEY,"
                + "title text,"
                + "description text);";
        db.execSQL(sql5);

        //创建婚恋问题
        String sql6 = "CREATE TABLE " + LOVE_NAME + "("
                + "_id INTEGER PRIMARY KEY,"
                + "title text,"
                + "description text);";
        db.execSQL(sql6);

        //创建人际关系
        String sql7 = "CREATE TABLE " + RELATIONSHIP_NAME + "("
                + "_id INTEGER PRIMARY KEY,"
                + "title text,"
                + "description text);";
        db.execSQL(sql7);

        //创建心理障碍
        String sql8 = "CREATE TABLE " + MENTAL_DISORDER_NAME + "("
                + "_id INTEGER PRIMARY KEY,"
                + "title text,"
                + "description text);";
        db.execSQL(sql8);


        //创建首页表
        String sql = "CREATE TABLE " + TABLE_NAME + "("
                + "_id INTEGER PRIMARY KEY,"
                + "title text,"
                + "description text);";
        db.execSQL(sql);
        //创建医生表
        String sql1 = "CREATE TABLE " + DOCTOR_NAME + "("
                + "_id INTEGER PRIMARY KEY,"
                + "title text,"
                + "description text);";

        db.execSQL(sql1);
        //创建用户表
        String userSql = "CREATE TABLE " + USER_INFO_TABLE + "("
                + "_id INTEGER PRIMARY KEY,"
                + "phone text,"
                + "password text);";
        db.execSQL(userSql);
        //创建心情日记表
        String diarySql = "CREATE TABLE " + DIARY_TABLE + "("
                + "_id INTEGER PRIMARY KEY,"
                + "description text);";

        db.execSQL(diarySql);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        Log.e("update", "update");
    }

}
